home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1998 April / EnigmA AMIGA RUN 26 (1998)(G.R. Edizioni)(IT)[!][issue 1998-04].iso / earkit / mailer / voodoo / rexx / emptyqueue.rexx next >
OS/2 REXX Batch file  |  1998-03-13  |  1KB  |  53 lines

  1. /* Empty the InetUtils SMTPd queue directory
  2.  * Useful with for example MLink, which can't run SMTPd itself.
  3.  * Adapted from Mike Meyer's mailq.rexx by Osma Ahvenlampi.
  4.  */
  5.  
  6. /* Make sure we have the libraries */
  7. if ~show('Libraries', 'rexxarplib.library') then
  8.     if ~addlib('rexxarplib.library', 0, -30) then do
  9.         say "No rexxarplib, so we can't scan the spool!"
  10.         exit
  11.         end
  12. if ~show('Libraries', 'rexxsupport.library') then
  13.     if ~addlib('rexxsupport.library', 0, -30) then do
  14.         say "No rexxsupport library, so we can't scan the spool!"
  15.         exit
  16.         end
  17.  
  18. /* Get the SMTPSPoolDir */
  19. spooldir = 'mail:spool' /*getuuenv('SMTPSPOOLDIR')*/
  20. if spooldir = "" then do
  21.     say "Can't find the name of the directory to scan."
  22.     exit
  23.     end
  24. old = pragma('Directory', spooldir)
  25.  
  26. /* Get a list of files in it */
  27. count = filelist('X.#?', files)
  28.  
  29. /* Now, process them */
  30. if count = 0 then
  31.     say "No files in the mail queue"
  32. else do
  33.     do i = 1 to count
  34.         parse value files.i with 'X.'queue
  35.         destination = getdestination(files.i)
  36.         if destination = "" then iterate
  37.         address command 'SMTPpost -n -t' destination 'D.'queue
  38.         if rc=0 then do
  39.             call delete(files.i)
  40.             call delete('D.'queue)
  41.         end
  42.     end
  43. exit
  44.  
  45. getdestination: procedure
  46.     parse arg file
  47.  
  48.     if ~open(in, file, 'Read') then return ""
  49.     call readln(in)
  50.     call readln(in)
  51.     addr = readln(in)
  52.     call close in
  53.     return addr